package com.anxin.act.cmd;

import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.runtime.AtomicOperation;

public class StartActCmd implements Command<Void> {
    private ActivityImpl _activity;

    private String _executionId;

    public StartActCmd(String executionId, ActivityImpl activity) {
        _activity = activity;
        _executionId = executionId;
    }

    //@Override
    public Void execute(CommandContext commandContext) {

        ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(_executionId);
        execution.setActivity(_activity);

        execution.performOperation(AtomicOperation.ACTIVITY_START);
        return null;
    }
}
